package com.wenshi.app.activity;

import android.os.Bundle;
import android.support.annotation.LayoutRes;


import com.wenshi.app.delegate.WsWiewDelegate;
import com.wenshi.view.IKeyValue;


/**
 * 这是所有控件类的父类
 */
public abstract class WsBaseActivity extends CommonActivity implements WsWiewDelegate.IReLoadContent, WsWiewDelegate.IInitData {


    /**
     * 这是代理
     */
    WsWiewDelegate wsWiewDelegate;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        super.setContentView(R.layout.wsview_activity_ws_base);
        wsWiewDelegate = new WsWiewDelegate(this, findViewById(R.id.base_root));

        __onCreate();

    }

    public void renderView(IKeyValue data) {

        getWsWiewDelegate().setHeadercenter(data.get("window_title"));
        super.renderView(wsWiewDelegate.root, data);

    }


    /**
     * 返回一个代理类
     */
    public WsWiewDelegate getWsWiewDelegate() {
        return wsWiewDelegate;
    }

    /**
     * WsBaseActivity开放的方法
     * 用来 自定义布局
     * 参数是 int id
     */
    @Override
    public void setContentView(@LayoutRes int layoutResID) {
        wsWiewDelegate.setContentView(layoutResID);
    }
}
